package operation.modules.operation.controller;

import operation.modules.operation.dto.TranslateDTO;
import operation.modules.operation.service.TranslateService;
import operation.util.ReqResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 翻译Controller
 */
@RestController
@RequestMapping("api/translate")
public class TranslateController {
    @Autowired
    private TranslateService translateService;

    /**
     * CN ->TW EN JA
     * @return
     */
    @RequestMapping("/translate")
    public ReqResult translate(@RequestParam Map<String, Object> params) {
        TranslateDTO res = translateService.translate(params);
        return ReqResult.ok().put("result", res);
    }

    /**
     * 打开Txt文件
     */
    @RequestMapping("/open-txt")
    public ReqResult openTxt() {
        translateService.openTxt();
        return ReqResult.ok();
    }
}
